$(function(){
	$("#user").focus(function(){
		$(this).attr("value","");
		$(this).css("border-color","#e90453");
	})
	$("#user").blur(function(){
		var reg1 = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
		var reg2 = /^1(3|5|7|8){1}(\d){9}$/;
		var str = $(this).val();
		if(str == ""){
				$(this).attr("placeholder","请输入您的手机号码/E-mail!")
				$(this).css("border-color","#e90453");
				$(this).parent().next().css({"display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px","color":"red"}).html("请输入手机号码/E-mail!");
			}else if(reg1.test(str)){
				$(this).css("border-color","#ccc");
				$(this).parent().next().css({"display":"block","color":"green","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("格式正确!");				
			}else if(reg2.test(str)){
				$(this).css("border-color","#ccc");
				$(this).parent().next().css({"display":"block","color":"green","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("格式正确");					
			}else{
				$(this).css("border-color","#e90453");
				$(this).parent().next().css({"display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px","color":"red"}).html("格式错误");				
			}
			})
	//验证码
	$("#yzm_a").click(function(){
			var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
			var list = [];
			var a = Math.floor(Math.random()*36);
			var b = Math.floor(Math.random()*36);
			var c = Math.floor(Math.random()*36);
			var d = Math.floor(Math.random()*36);
			list = [arr[a],arr[b],arr[c],arr[d]];
			$("#yzm_pic").html(list);
		})	
		$("#yzm_pic").click(function(){
					var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
					var list = [];
					var a = Math.floor(Math.random()*36);
					var b = Math.floor(Math.random()*36);
					var c = Math.floor(Math.random()*36);
					var d = Math.floor(Math.random()*36);
					list = [arr[a],arr[b],arr[c],arr[d]];
					$(this).html(list);
		})		
	
	
	$("#yzm").focus(function(){
		//$(this).attr("value","");
		$(this).css("border-color","#e90453");
		var arr = [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','l','r','s','t','u','v','w','x','y','z'];
			var list = [];
			var a = Math.floor(Math.random()*36);
			var b = Math.floor(Math.random()*36);
			var c = Math.floor(Math.random()*36);
			var d = Math.floor(Math.random()*36);
			list = [arr[a],arr[b],arr[c],arr[d]];
			$("#yzm_pic").html(list);
	})
	$("#yzm").blur(function(){
		var str1 = $("#yzm_pic").html();
		var str2 = $(this).val();
		if(str2 == ""){
			$(this).css("border-color","red");
			$(this).parent().next().css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("请输入验证码!");
		}else if(str1 != str2){
			$(this).parent().next().css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("验证码错误!");			
		}else{
			$(this).css("border-color","#ccc");
			$(this).parent().next().css({"display":"block","color":"green","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("验证码正确!");						
		}
	})
	
	
	
	//密码
	$("#pass").focus(function(){
		$(this).css("border-color","#e90453");	
		var oP = $(this).parent().next();
		var reg = 	/^[a-zA-Z0-9_-]{6,25}$/;
		$(window).keydown(function(){
			var str = $("#pass").val();
			if(reg.test(str)){
				if(str.length < 8){
					oP.css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("安全性弱！")					
				}else if(str.length < 16){
					oP.css({"color":"#f60","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("安全性中！")
				}else{
					oP.css({"color":"green","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("安全性强！")
				}
			}else{
				oP.css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("格式不正确!")
			}
		})
	})
	
	$("#pass").blur(function(){
		if($(this).val() == ""){
			$(this).css("border-color","red");
			$(this).parent().next().css({"display":"block","color":"red","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("请输入密码！");			
		}else{
			$(this).css("border-color","#ccc");
		}
		
	})
	
	$("#pass2").focus(function(){
		$(this).attr("value","");
		$(this).css("border-color","#e90453");
	})
	
	
	$("#pass2").blur(function(){
		var str = $("#pass").val();
		if($(this).val()==""){
			$(this).parent().next().css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("请输入密码!");
			$(this).css("border-color","red");
		}else{
			if(str != $(this).val()){
				$(this).parent().next().css({"color":"red","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -262px"}).html("密码不一致!");
			}else{
				$(this).parent().next().css({"color":"green","display":"block","background":"url(../img/zhuce/client-register-button.png) no-repeat 0 -232px"}).html("密码一致！");	
				$(this).css("border-color","#ccc");
				$("#zhuce").click(function(){
					var user = $("#user").val();
					var pass = $("#pass2").val();
					setCookie(user,user,setCookieDate(7));
					setCookie(pass,pass,setCookieDate(7));
					window.location.href="denglu.html";
				})			
			}		
		}
	})


})







